80381900: 27 bd ff c0  ADDIU sp, sp, 0xffffffc0 (-64)
80381904: af bf 00 1c  SW ra, sp, 0x1c (28)
80381908: af a6 00 48  SW a2, sp, 0x48 (72)                    [sp + 0x48] === arg3
8038190c: af a7 00 4c  SW a3, sp, 0x4c (76)                    [sp + 0x4c] === arg4
80381910: e7 ac 00 40  SWC1 f12, sp, 0x40 (64)                 [sp + 0x40] === arg1
80381914: e7 ae 00 44  SWC1 f14, sp, 0x44 (68)                 [sp + 0x44] === arg2

80381918: 3c 01 80 39  LUI at, 0x8039 (32825)
8038191c: c4 24 bb a0  LWC1 f4, at, 0xffffbba0 (-17504)
80381920: e7 a4 00 2c  SWC1 f4, sp, 0x2c (44)              [sp + 0x2c] = *(0x8038bba0);

80381924: 3c 01 80 39  LUI at, 0x8039 (32825)
80381928: c4 26 bb a4  LWC1 f6, at, 0xffffbba4 (-17500)
8038192c: e7 a6 00 28  SWC1 f6, sp, 0x28 (40)              [sp + 0x28] = *(0x8038bba4);

80381930: c7 a8 00 40  LWC1 f8, sp, 0x40 (64)
80381934: 46 00 42 8d  TRUNC.W.S f10, f8
80381938: 44 0f 50 00  MFC1 t7, f10
8038193c: 00 00 00 00  NOP
80381940: a7 af 00 26  SH t7, sp, 0x26 (38)                [sp + 0x26] = (short int)arg1;

80381944: c7 b0 00 44  LWC1 f16, sp, 0x44 (68)
80381948: 46 00 84 8d  TRUNC.W.S f18, f16
8038194c: 44 19 90 00  MFC1 t9, f18
80381950: 00 00 00 00  NOP
80381954: a7 b9 00 24  SH t9, sp, 0x24 (36)                [sp + 0x24] = (short int)arg2;

80381958: c7 a4 00 48  LWC1 f4, sp, 0x48 (72)
8038195c: 46 00 21 8d  TRUNC.W.S f6, f4
80381960: 44 09 30 00  MFC1 t1, f6
80381964: 00 00 00 00  NOP
80381968: a7 a9 00 22  SH t1, sp, 0x22 (34)                [sp + 0x22] = (short int)arg3;

8038196c: 8f aa 00 4c  LW t2, sp, 0x4c (76)
80381970: ad 40 00 00  SW r0, t2, 0x0 (0)                  *arg4 = 0;

80381974: 87 ab 00 26  LH t3, sp, 0x26 (38)
80381978: 29 61 e0 01  SLTI at, t3, 0xffffe001 (-8191)
8038197c: 14 20 00 04  BNE at, r0, 0x80381990 (pc + 0x10)      if ([sp + 0x26] < -0x1fff) goto 0x80381990;
80381980: 00 00 00 00  NOP
80381984: 29 61 20 00  SLTI at, t3, 0x2000 (8192)
80381988: 14 20 00 03  BNE at, r0, 0x80381998 (pc + 0xc)       if ([sp + 0x26] < 0x2000) goto 0x80381998;
8038198c: 00 00 00 00  NOP
80381990: 10 00 00 7f  BEQ r0, r0, 0x80381b90 (pc + 0x1fc) if ([sp + 0x26] < -0x1fff || [sp + 0x26] >= 0x2000) return [sp + 0x2c];
80381994: c7 a0 00 2c  LWC1 f0, sp, 0x2c (44)

80381998: 87 ac 00 22  LH t4, sp, 0x22 (34)
8038199c: 29 81 e0 01  SLTI at, t4, 0xffffe001 (-8191)
803819a0: 14 20 00 04  BNE at, r0, 0x803819b4 (pc + 0x10)
803819a4: 00 00 00 00  NOP
803819a8: 29 81 20 00  SLTI at, t4, 0x2000 (8192)
803819ac: 14 20 00 03  BNE at, r0, 0x803819bc (pc + 0xc)
803819b0: 00 00 00 00  NOP
803819b4: 10 00 00 76  BEQ r0, r0, 0x80381b90 (pc + 0x1d8) if ([sp + 0x22] < -0x1fff || [sp + 0x22] >= 0x2000) return [sp + 0x2c];
803819b8: c7 a0 00 2c  LWC1 f0, sp, 0x2c (44)

803819bc: 87 ad 00 26  LH t5, sp, 0x26 (38)
803819c0: 25 ae 20 00  ADDIU t6, t5, 0x2000 (8192)
803819c4: 05 c1 00 03  BGEZ t6, 0x803819d4 (pc + 0xc)          t7 = ([sp + 0x26] + 0x2000)>>10
803819c8: 00 0e 7a 83  SRA t7, t6, 0xa (10)                    if ([sp + 0x26] >= 0x2000) goto 803819d4
803819cc: 25 c1 03 ff  ADDIU at, t6, 0x3ff (1023)
803819d0: 00 01 7a 83  SRA t7, at, 0xa (10)                    t7 = ([sp + 0x26] + 0x23ff)>>10
803819d4: 31 f8 00 0f  ANDI t8, t7, 0xf (15)
803819d8: a7 b8 00 3c  SH t8, sp, 0x3c (60)                [sp + 0x3c] = 0xf & (([sp + 0x26] < 0x2000)?(([sp + 0x26] + 0x2000)>>10):(([sp + 0x26] + 0x23ff)>>10));

803819dc: 87 b9 00 22  LH t9, sp, 0x22 (34)
803819e0: 27 28 20 00  ADDIU t0, t9, 0x2000 (8192)
803819e4: 05 01 00 03  BGEZ t0, 0x803819f4 (pc + 0xc)
803819e8: 00 08 4a 83  SRA t1, t0, 0xa (10)
803819ec: 25 01 03 ff  ADDIU at, t0, 0x3ff (1023)
803819f0: 00 01 4a 83  SRA t1, at, 0xa (10)
803819f4: 31 2a 00 0f  ANDI t2, t1, 0xf (15)
803819f8: a7 aa 00 3e  SH t2, sp, 0x3e (62)                [sp + 0x3e] = 0xf & (([sp + 0x22] < 0x2000)?(([sp + 0x22] + 0x2000)>>10):(([sp + 0x22] + 0x23ff)>>10));

803819fc: 87 ab 00 3e  LH t3, sp, 0x3e (62)
80381a00: 87 ad 00 3c  LH t5, sp, 0x3c (60)
80381a04: 3c 18 80 39  LUI t8, 0x8039 (32825)
80381a08: 00 0b 60 80  SLL t4, t3, 0x2 (2)
80381a0c: 00 0d 70 80  SLL t6, t5, 0x2 (2)
80381a10: 01 8b 60 23  SUBU t4, t4, t3                         t4 = [sp + 0x3e]*3
80381a14: 01 cd 70 23  SUBU t6, t6, t5                         t6 = [sp + 0x3c]*3
80381a18: 00 0e 70 c0  SLL t6, t6, 0x3 (3)                     t6 = [sp + 0x3c]*24
80381a1c: 00 0c 61 c0  SLL t4, t4, 0x7 (7)                     t4 = [sp + 0x3e]*24*16
80381a20: 01 8e 78 21  ADDU t7, t4, t6                         t7 = [sp + 0x3e]*24*16 + [sp + 0x3c]*24
80381a24: 03 0f c0 21  ADDU t8, t8, t7                         t8 = 0x80390000 + [sp + 0x3e]*24*16 + [sp + 0x3c]*24
80381a28: 8f 18 d6 98  LW t8, t8, 0xffffd698 (-10600)
80381a2c: af b8 00 30  SW t8, sp, 0x30 (48)                [sp + 0x30] = (0x8038d698)[[sp + 0x3e]][sp + 0x3c]];

80381a30: 27 b9 00 28  ADDIU t9, sp, 0x28 (40)
80381a34: af b9 00 10  SW t9, sp, 0x10 (16)
80381a38: 8f a4 00 30  LW a0, sp, 0x30 (48)
80381a3c: 87 a5 00 26  LH a1, sp, 0x26 (38)
80381a40: 87 a6 00 24  LH a2, sp, 0x24 (36)
80381a44: 0c 0e 05 5b  JAL 0x8038156c (-2143808148)        [sp + 0x34] = 0x8038156c([sp + 0x30], [sp + 0x26], [sp + 0x24], [sp + 0x22], [sp + 0x28]);
80381a48: 87 a7 00 22  LH a3, sp, 0x22 (34)
80381a4c: af a2 00 34  SW v0, sp, 0x34 (52)

80381a50: 87 a8 00 3e  LH t0, sp, 0x3e (62)
80381a54: 87 aa 00 3c  LH t2, sp, 0x3c (60)
80381a58: 3c 0c 80 39  LUI t4, 0x8039 (32825)
80381a5c: 00 08 48 80  SLL t1, t0, 0x2 (2)
80381a60: 00 0a 58 80  SLL t3, t2, 0x2 (2)
80381a64: 01 28 48 23  SUBU t1, t1, t0
80381a68: 01 6a 58 23  SUBU t3, t3, t2
80381a6c: 00 0b 58 c0  SLL t3, t3, 0x3 (3)
80381a70: 00 09 49 c0  SLL t1, t1, 0x7 (7)
80381a74: 01 2b 68 21  ADDU t5, t1, t3
80381a78: 01 8d 60 21  ADDU t4, t4, t5
80381a7c: 8d 8c be 98  LW t4, t4, 0xffffbe98 (-16744)
80381a80: af ac 00 30  SW t4, sp, 0x30 (48)                [sp + 0x30] = (0x8038be98)[[sp + 0x3e]][sp + 0x3c]];

80381a84: 27 ae 00 2c  ADDIU t6, sp, 0x2c (44)
80381a88: af ae 00 10  SW t6, sp, 0x10 (16)
80381a8c: 8f a4 00 30  LW a0, sp, 0x30 (48)
80381a90: 87 a5 00 26  LH a1, sp, 0x26 (38)
80381a94: 87 a6 00 24  LH a2, sp, 0x24 (36)
80381a98: 0c 0e 05 5b  JAL 0x8038156c (-2143808148)        [sp + 0x38] = 0x8038156c([sp + 0x30], [sp + 0x26], [sp + 0x24], [sp + 0x22], [sp + 0x2c]);
80381a9c: 87 a7 00 22  LH a3, sp, 0x22 (34)
80381aa0: af a2 00 38  SW v0, sp, 0x38 (56)

80381aa4: 3c 0f 80 36  LUI t7, 0x8036 (32822)
80381aa8: 85 ef 11 82  LH t7, t7, 0x1182 (4482)
80381aac: 15 e0 00 18  BNE t7, r0, 0x80381b10 (pc + 0x60)  if (*(0x80361182)) goto 0x80381b10;
80381ab0: 00 00 00 00  NOP

80381ab4: 8f b8 00 38  LW t8, sp, 0x38 (56)
80381ab8: 13 00 00 13  BEQ r0, t8, 0x80381b08 (pc + 0x4c)
80381abc: 00 00 00 00  NOP
80381ac0: 87 19 00 00  LH t9, t8, 0x0 (0)
80381ac4: 24 01 00 12  ADDIU at, r0, 0x12 (18)
80381ac8: 17 21 00 0f  BNE t9, at, 0x80381b08 (pc + 0x3c)  if (![sp + 0x38] || *[sp + 0x38] != 18) goto 0x80381b08;
80381acc: 00 00 00 00  NOP

80381ad0: 3c 01 43 48  LUI at, 0x4348 (17224)
80381ad4: 44 81 50 00  MTC1 at, f10                            f10 = 200.0
80381ad8: c7 a8 00 2c  LWC1 f8, sp, 0x2c (44)
80381adc: 27 aa 00 2c  ADDIU t2, sp, 0x2c (44)                 t2 = &[sp + 0x2c]
80381ae0: af aa 00 10  SW t2, sp, 0x10 (16)
80381ae4: 46 0a 44 01  SUB.S f16, f8, f10                      f16 = [sp + 0x2c] - 200.0
80381ae8: 8f a4 00 30  LW a0, sp, 0x30 (48)
80381aec: 87 a5 00 26  LH a1, sp, 0x26 (38)
80381af0: 87 a7 00 22  LH a3, sp, 0x22 (34)
80381af4: 46 00 84 8d  TRUNC.W.S f18, f16
80381af8: 44 06 90 00  MFC1 a2, f18
80381afc: 0c 0e 05 5b  JAL 0x8038156c (-2143808148)        [sp + 0x38] = 0x8038156c([sp + 0x30], [sp + 0x26], (int)([sp + 0x2c] - 200.0), [sp + 0x22], &[sp + 0x2c]);
80381b00: 00 00 00 00  NOP
80381b04: af a2 00 38  SW v0, sp, 0x38 (56)

*
80381b08: 10 00 00 03  BEQ r0, r0, 0x80381b18 (pc + 0xc)   goto 0x80381b18;
80381b0c: 00 00 00 00  NOP

*
80381b10: 3c 01 80 36  LUI at, 0x8036 (32822)
80381b14: a4 20 11 82  SH r0, at, 0x1182 (4482)            *(0x80361182) = 0;

*
80381b18: 8f a9 00 38  LW t1, sp, 0x38 (56)
80381b1c: 15 20 00 06  BNE t1, r0, 0x80381b38 (pc + 0x18)  if ([sp + 0x38]) goto 0x80381b38;
80381b20: 00 00 00 00  NOP

80381b24: 3c 0b 80 34  LUI t3, 0x8034 (32820)
80381b28: 8d 6b d2 64  LW t3, t3, 0xffffd264 (-11676)
80381b2c: 3c 01 80 34  LUI at, 0x8034 (32820)
80381b30: 25 6d 00 01  ADDIU t5, t3, 0x1 (1)
80381b34: ac 2d d2 64  SW t5, at, 0xffffd264 (-11676)      *(0x8033d264)++;

*
80381b38: c7 a4 00 28  LWC1 f4, sp, 0x28 (40)
80381b3c: c7 a6 00 2c  LWC1 f6, sp, 0x2c (44)
80381b40: 46 04 30 3c  C.LT.S f6, f4
80381b44: 00 00 00 00  NOP
80381b48: 45 00 00 05  BC1F 0x80381b60 (pc + 0x14)         if ([sp + 0x28] < [sp + 0x2c]) goto 0x80381b60;
80381b4c: 00 00 00 00  NOP

80381b50: 8f ac 00 34  LW t4, sp, 0x34 (52)
80381b54: af ac 00 38  SW t4, sp, 0x38 (56)                [sp + 0x38] = [sp + 0x34];

80381b58: c7 a8 00 28  LWC1 f8, sp, 0x28 (40)
80381b5c: e7 a8 00 2c  SWC1 f8, sp, 0x2c (44)              [sp + 0x2c] = [sp + 0x28];

*
80381b60: 8f ae 00 38  LW t6, sp, 0x38 (56)
80381b64: 8f af 00 4c  LW t7, sp, 0x4c (76)
80381b68: ad ee 00 00  SW t6, t7, 0x0 (0)                  *arg4 = [sp + 0x38];

80381b6c: 3c 18 80 34  LUI t8, 0x8034 (32820)
80381b70: 87 18 d2 74  LH t8, t8, 0xffffd274 (-11660)
80381b74: 3c 01 80 34  LUI at, 0x8034 (32820)
80381b78: 27 19 00 01  ADDIU t9, t8, 0x1 (1)
80381b7c: a4 39 d2 74  SH t9, at, 0xffffd274 (-11660)      *(0x8033d274)++;

80381b80: 10 00 00 03  BEQ r0, r0, 0x80381b90 (pc + 0xc)
80381b84: c7 a0 00 2c  LWC1 f0, sp, 0x2c (44)
80381b88: 10 00 00 01  BEQ r0, r0, 0x80381b90 (pc + 0x4)
80381b8c: 00 00 00 00  NOP
80381b90: 8f bf 00 1c  LW ra, sp, 0x1c (28)
80381b94: 27 bd 00 40  ADDIU sp, sp, 0x40 (64)
80381b98: 03 e0 00 08  JR ra                               return [sp + 0x2c];
80381b9c: 00 00 00 00  NOP


[sp + 0x2c] = *(0x8038bba0);
[sp + 0x28] = *(0x8038bba4);
[sp + 0x26] = (short int)arg1;
[sp + 0x24] = (short int)arg2;
[sp + 0x22] = (short int)arg3;
*arg4 = 0;
if ([sp + 0x26] < -0x1fff || [sp + 0x26] >= 0x2000) return [sp + 0x2c];
if ([sp + 0x22] < -0x1fff || [sp + 0x22] >= 0x2000) return [sp + 0x2c];
[sp + 0x3c] = 0xf & (([sp + 0x26] < 0x2000)?(([sp + 0x26] + 0x2000)>>10):(([sp + 0x26] + 0x23ff)>>10));
[sp + 0x3e] = 0xf & (([sp + 0x22] < 0x2000)?(([sp + 0x22] + 0x2000)>>10):(([sp + 0x22] + 0x23ff)>>10));
[sp + 0x30] = (0x8038d698)[[sp + 0x3e]][sp + 0x3c]];
[sp + 0x34] = 0x8038156c([sp + 0x30], [sp + 0x26], [sp + 0x24], [sp + 0x22], [sp + 0x28]);
[sp + 0x30] = (0x8038be98)[[sp + 0x3e]][sp + 0x3c]];
[sp + 0x38] = 0x8038156c([sp + 0x30], [sp + 0x26], [sp + 0x24], [sp + 0x22], [sp + 0x2c]);

if (*(0x80361182)) goto 0x80381b10;
    if (![sp + 0x38] || *[sp + 0x38] != 18) goto 0x80381b08;
        [sp + 0x38] = 0x8038156c([sp + 0x30], [sp + 0x26], (int)([sp + 0x2c] - 200.0), [sp + 0x22], &[sp + 0x2c]);
    80381b08:
goto 0x80381b18;
80381b10:
    *(0x80361182) = 0;
80381b18:

if ([sp + 0x38]) goto 0x80381b38;
    *(0x8033d264)++;
80381b38:

if ([sp + 0x28] < [sp + 0x2c]) goto 0x80381b60;
    [sp + 0x38] = [sp + 0x34];
    [sp + 0x2c] = [sp + 0x28];
80381b60:
*arg4 = [sp + 0x38];
*(0x8033d274)++;
return [sp + 0x2c];


float proc0x80381900(float x, float y, float z, short **arg4)
{

    short hi_z    /* [sp + 0x3e] */
    short hi_x    /* [sp + 0x3c] */
    short *ptr2   /* [sp + 0x38] */
    short *ptr1   /* [sp + 0x34] */
    ???32 u_lv    /* [sp + 0x30] */
    float uy1     /* [sp + 0x2c] */
    float uy2     /* [sp + 0x28] */
    short xs;     /* [sp + 0x26] */
    short ys;     /* [sp + 0x24] */
    short zs;     /* [sp + 0x22] */


    uy1 = *(0x8038bba0);
    uy2 = *(0x8038bba4);
    
    xs = (short int)arg1;
    ys = (short int)arg2;
    zs = (short int)arg3;
    *arg4 = NULL;
    
    if (xs < -0x1fff || xs >= 0x2000) {
        return uy1;
    }
    if (zs < -0x1fff || zs >= 0x2000) {
        return uy1;
    }

    hi_x = 0xf & ((xs < 0x2000)?((xs + 0x2000)>>10):((xs + 0x23ff)>>10));
    hi_z = 0xf & ((zs < 0x2000)?((zs + 0x2000)>>10):((zs + 0x23ff)>>10));
    
    u_lv = (0x8038d698)[hi_z][hi_x];
    ptr1 = 0x8038156c(u_lv, xs, ys, zs, uy2);
    
    u_lv = (0x8038be98)[hi_z][hi_x];
    ptr2 = 0x8038156c(u_lv, xs, ys, zs, uy1);
    
    if (!*(0x80361182)) {
        if (ptr2 && *ptr2 == 18) {
            ptr2 = 0x8038156c(u_lv, xs, (int)(uy1 - 200.0), zs, &uy1);
          }
    } else {
        *(0x80361182) = 0;
    }
    
    if (!ptr2) {
        *(0x8033d264)++;
    }
    
    if (uy2 >= uy1) {
        ptr2 = ptr1;
        uy1 = uy2;
    }
    *arg4 = ptr2;
    *(0x8033d274)++;
    return uy1;
}
